#include <iostream>
using namespace std;
string s = "123456789ABCDEF";
void x_to_m(int x,int m)
{
	if(x >= m)
	x_to_m(x / 10,m);
	cout << s[x % 10];
}
int main()
{
	int x,m;
	cin >> x >> m;
	x_to_m(x,m);
	return 0;
}

